package com.hccl.util;

import java.io.File;
import java.io.IOException;

/**
 * Created by sunjia on 2018/4/11.
 */
public class DeleteFile {

    public static void delete(File file) throws IOException {
        try{
            if (file.isDirectory()) {
                if (file.list().length == 0) {
                    file.delete();
                }else {
                    String files[] = file.list();
                    for (String temp : files) {
                        File fileDelete = new File(file, temp);
                        delete(fileDelete);
                    }
                    if (file.list().length == 0) {
                        file.delete();
                    }
                }
            } else {
                file.delete();
            }
        }catch(IOException e){return;}
    }
}
